import React from 'react';
import { createAppContainer, createStackNavigator, createSwitchNavigator } from 'react-navigation';
import * as wechat from 'react-native-wechat';
import NavigationService from '../constants/NavigationService';
import LoginScreen from '../screen/LoginScreen';
import BigImageScreen from '../screen/BigImageScreen';
import BigImageListScreen from '../screen/BigImageListScreen';
import MainTabNavigator from './MainTabNavigator';
import WelcomeScreen from '../screen/WelcomeScreen';
import ChooseRegisterScreen from '../screen/ChooseRegisterScreen';
import RegisterScreen from '../screen/RegisterScreen';
import CompanyRegisterScreen from '../screen/CompanyRegisterScreen';
import ForgetPasswordScreen from '../screen/ForgetPasswordScreen';
import MineInfoScreen from '../screen/MineInfoScreen';
import PersonalAuthenticationScreen from '../screen/PersonalAuthenticationScreen';
import MerchantCertificationScreen from '../screen/MerchantCertificationScreen';
import EnterpriseCertificationScreen from '../screen/EnterpriseCertificationScreen';
import SettingScreen from '../screen/SettingScreen';
import EnterpriseRealNameCertificationScreen from '../screen/EnterpriseRealNameCertificationScreen';
import EnterpriseIndeedCertificationScreen from '../screen/EnterpriseIndeedCertificationScreen';
import PerfectInformationScreen from '../screen/PerfectInformationScreen';
import BankCardListScreen from '../screen/BankCardListScreen';
import AddBankScreen from '../screen/AddBankScreen';
import AccountSecurityScreen from '../screen/AccountSecurityScreen';
import ChangePhoneScreen from '../screen/ChangePhoneScreen';
import ChangePasswordScreen from '../screen/ChangePasswordScreen';
import OpinionScreen from '../screen/OpinionScreen';
import AboutScreen from '../screen/AboutScreen';
import AccountManagementScreen from '../screen/AccountManagementScreen';
import AddAccountScreen from '../screen/AddAccountScreen';
import RedEnvelopesScreen from '../screen/RedEnvelopesScreen';
import SendRedEnvelopesScreen from '../screen/SendRedEnvelopesScreen';
import MyWalletScreen from '../screen/MyWalletScreen';
import WithdrawalScreen from '../screen/WithdrawalScreen';
import MyFollowScreen from '../screen/MyFollowScreen';
import MyDemandScreen from '../screen/MyDemandScreen';
import DemandDetailScreen from '../screen/DemandDetailScreen';
import QuoteDetailScreen from '../screen/QuoteDetailScreen';
import SigningContractScreen from '../screen/SigningContractScreen';
import SearchScreen from '../screen/SearchScreen';
import MessageScreen from '../screen/MessageScreen';
import GoodsDetailScreen from '../screen/GoodsDetailScreen';
import ReleaseDemandScreen from '../screen/ReleaseDemandScreen';
import ChooseCateScreen from '../screen/ChooseCateScreen';
import AddAddressScreen from '../screen/AddAddressScreen';
import QuoteScreen from '../screen/QuoteScreen';
import SearchOrderScreen from '../screen/SearchOrderScreen';
import ServiceProviderListScreen from '../screen/ServiceProviderListScreen';
import ServiceProviderDetailScreen from '../screen/ServiceProviderDetailScreen';
import ChooseMyDemandScreen from '../screen/ChooseMyDemandScreen';
import ShowSDRZScreen from '../screen/ShowSDRZScreen';
import ShowSMRZScreen from '../screen/ShowSMRZScreen';
import ConfirmOrderScreen from '../screen/ConfirmOrderScreen';
import MyOrderListScreen from '../screen/MyOrderListScreen';
import GoodsOrderDetailScreen from '../screen/GoodsOrderDetailScreen';
import NeedsOrderDetailScreen from '../screen/NeedsOrderDetailScreen';
import EvaluateServiceScreen from '../screen/EvaluateServiceScreen';
import EvaluateEmployerScreen from '../screen/EvaluateEmployerScreen';
import BidOrderDetailScreen from '../screen/BidOrderDetailScreen';
import AddressManagementScreen from '../screen/AddressManagementScreen';
import MeAddAddressScreen from '../screen/MeAddAddressScreen';
import MessageDetailScreen from '../screen/MessageDetailScreen';

const LoginStack = createStackNavigator({
    Welcome: WelcomeScreen,//欢迎页
    Login: LoginScreen,//登录界面
    ChooseRegister: ChooseRegisterScreen,//选择注册界面
    Register: RegisterScreen,//个人注册页面
    CompanyRegister: CompanyRegisterScreen,//公司注册页面
    ForgetPassword: ForgetPasswordScreen,//忘记密码界面
}, {
    headerMode: 'none',
    initialRouteName: 'Welcome'
})

const MainStack = createStackNavigator({
    Main: MainTabNavigator,//主页
    MineInfo: MineInfoScreen,//个人资料界面
    PersonalAuthentication: PersonalAuthenticationScreen,//个人实名认证
    MerchantCertification: MerchantCertificationScreen,//公司认证选择界面
    EnterpriseRealNameCertification: EnterpriseRealNameCertificationScreen,//企业实名认证
    EnterpriseCertification: EnterpriseCertificationScreen,//企业认证界面
    EnterpriseIndeedCertification: EnterpriseIndeedCertificationScreen,//实地认证页面
    PerfectInformation: PerfectInformationScreen,//完善信息
    BankCardList: BankCardListScreen,//银行卡列表界面
    AddBank: AddBankScreen,//绑定银行卡界面
    Setting: SettingScreen,//设置界面
    AccountSecurity: AccountSecurityScreen,//账号安全
    MainForgetPassword: ForgetPasswordScreen,//忘记密码界面 
    ChangePhone: ChangePhoneScreen,//修改手机号
    ChangePassword: ChangePasswordScreen,//修改密码
    Opinion: OpinionScreen,//意见反馈
    About: AboutScreen,//关于我们
    AccountManagement: AccountManagementScreen,//子账户管理
    AddAccount: AddAccountScreen,//添加子账户
    RedEnvelopes: RedEnvelopesScreen,//广告红包
    SendRedEnvelopes: SendRedEnvelopesScreen,//发红包
    MyWallet: MyWalletScreen,//我的钱包
    Withdrawal: WithdrawalScreen,//提现
    MyFollow: MyFollowScreen,//我的关注
    MyDemand: MyDemandScreen,//我的需求
    DemandDetail: DemandDetailScreen,//需求详情
    QuoteDetail: QuoteDetailScreen,//报价详情
    SigningContract: SigningContractScreen,//签署电子合同
    Search: SearchScreen,//搜索界面
    Message: MessageScreen,//消息界面
    MessageDetail: MessageDetailScreen,//消息详情界面
    GoodsDetail: GoodsDetailScreen,//商品详情界面
    ReleaseDemand: ReleaseDemandScreen,//发布需求
    ChooseCate: ChooseCateScreen,//选择类别的界面
    AddAddress: AddAddressScreen,//添加收货地址
    Quote: QuoteScreen,//我要报价界面
    SearchOrder: SearchOrderScreen,//搜索工单界面
    ServiceProviderList: ServiceProviderListScreen,//服务商列表界面
    ServiceProviderDetail: ServiceProviderDetailScreen,//服务商详情
    ChooseMyDemand: ChooseMyDemandScreen,//邀请报价后选择我的需求
    ShowSDRZ: ShowSDRZScreen,//企业实地认证展示页
    ShowSMRZ: ShowSMRZScreen,//企业实名认证展示页
    ConfirmOrder: ConfirmOrderScreen,//确认订单界面
    MyOrderList: MyOrderListScreen,//订单中心
    GoodsOrderDetail: GoodsOrderDetailScreen,//商品订单详情界面
    NeedsOrderDetail: NeedsOrderDetailScreen,//需求订单详情
    EvaluateService: EvaluateServiceScreen,//评价服务商界面
    EvaluateEmployer: EvaluateEmployerScreen,//评价雇主界面
    BidOrderDetail: BidOrderDetailScreen,//投标订单详情界面
    AddressManagement: AddressManagementScreen,//我的收货地址
    MeAddAddress: MeAddAddressScreen,//我的添加收货地址
    BigImage: BigImageScreen,//查看大图
    BigImageList: BigImageListScreen,//查看大图列表
}, {
    headerMode: 'none',
    initialRouteName: 'Main'
})

//NavigationService被设置为最顶端的路由，在栈内使用时，想切换到另外栈时可以使用NavigationService.navigate('MainStack')进行栈的切换,写这个是因为登录流程和主界面要分开在不同的栈
const AppContainer = createAppContainer(createSwitchNavigator({
    LoginStack: LoginStack,
    MainStack: MainStack
}, {
    headerMode: 'none',
    initialRouteName: 'LoginStack'
}));

export default class App extends React.Component {
    render() {

        global.userInfo = {}
        global.companyInfo = {}
        global.locationInfo = {}

        global.currentAndroidVersion = 1
        global.currentIosVersion = 1

        wechat.registerApp('wxf5b4ece122eabc54');

        return (
            <AppContainer
                ref={navigatorRef => {
                    NavigationService.setTopLevelNavigator(navigatorRef);
                }}
            />
        );
    }
}